using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;

public partial class Admin_danhmucupdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();

    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_madanhmuc.Text = id.ToString();

            tbdanhmuc danhmuc = tbdanhmucBUS.GetByID(id);
            txt_tensp.Text = danhmuc.Tenmh;
           
        }
        catch
        {
            Response.Redirect("~/Admin/danhmuclist.aspx");
        }
    }

    protected void btn_Update_Click(object sender, EventArgs e)
    {
        {
            try
            {
                int id = int.Parse(Request.QueryString["id"].ToString());
                tbdanhmuc danhmuc = tbdanhmucBUS.GetByID(id);
                danhmuc.Tendanhmuc = txt_tendanhmuc.Text;
               
                tbdanhmucBUS.Update(danhmuc);


            }
            catch (Exception ex)
            {
                Response.Redirect("~/Admin/danhmuclist.aspx");
            }
            Response.Redirect(Request.RawUrl);
        }
    }
}
